{% extends 'data/highstock.html' %}
{% block title %}{{series.name}}{% endblock title %}
{% block navbar %}{% endblock %}
{% block admin_url %}series/{{object.id}}{% endblock %}
{% block chartloader %}
	<script>
		function fetchSeries() {
		    $.ajax({
			    url: '/data/get/series/{{object.id}}',
			    datatype: "json",
			    beforeSend: function(hdr) {
				  	var chart = $('#container').highcharts();
			    	chart.showLoading("Gegevens ophalen...");
			    	return true;
			    },
			    success: function(data) {
				  	var chart = $('#container').highcharts();
			    	chart.series[0].setData(data);
			    },
			    error: function(hdr,status,errorThrown) {
			    	alert("Fout tijdens laden van tijdreeks: " + errorThrown);
			    },
			    complete: function(hdr, status) {
				  	var chart = $('#container').highcharts();
			    	chart.hideLoading();
			    }
		    });
		}
		
		$(function () {
		  var opt = {{options|safe}};
		  opt.chart.events.load = fetchSeries;
		  chart = $('#container').highcharts('StockChart', 	opt);
		});
	</script>
{% endblock %}
{% block content %}
{{ block.super }}
<br/>
<div class="text-center">
<a href="{% url 'acacia:series-csv' object.id %}" class="btn btn-primary active" data-toggle="tooltip" title="Tijdreeks downloaden als csv bestand" id="download">Downloaden</a>
</div>
{% endblock %}
